#include "../logs/whlog.h"
#include <unistd.h>

void test_log(const std::string &name)
{
    INFO("%s","测试开始");
    whlog::Logger::ptr logger = whlog::getLogger("async_logger");
    logger->debug("%s","测试日志");
    logger->info("%s","测试日志");
    logger->warn("%s","测试日志");
    logger->error("%s","测试日志");
    logger->fatal("%s","测试日志");
    INFO("%s","测试完毕");
}

int main()
{
    // 同步日志器简单测试
    std::unique_ptr<whlog::LoggerBuilder> builder(new whlog::GlobalLoggerBuilder());
    builder->buildLoggerName("sync_logger");
    builder->buildLoggerLevel(whlog::LogLevel::value::DEBUG);
    builder->buildLogformatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(whlog::LoggerType::LOGGER_SYNC);
    builder->buildLogSink<whlog::StdoutSink>();
    builder->buildLogSink<whlog::FileSink>("./logfile/sync.log");
    builder->buildLogSink<whlog::RollBySizeSink>("./logfile/roll-async-by-size",1024*1024);
    builder->build();
    test_log("async_logger");

    return 0;
}